<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>比值函数</title>
</head>
<body>
<h1>JavaScript 数组排序</h1>

<p>单击按钮可按字母顺序或数字顺序对数组进行排序。</p>

<button onclick="myFunction1()">以字母形式排序</button>
<button onclick="myFunction2()">以数字形式排序</button>

<p id="demo"></p>

<script>
    var points = [1,25,10,100,35];
    document.getElementById("demo").innerHTML = points;

    function myFunction1(){
        points.sort();
        document.getElementById("demo").innerHTML = points;
    }
    function myFunction2(){
        points.sort(function (a, b){return a - b;})
        document.getElementById("demo").innerHTML = points;
    }
</script>
</body>
</html>